# coding: utf8
# datetime: 2021-04-11
# 题目地址: https://leetcode-cn.com/problems/largest-number/

from typing import List

class Solution:
    def largestNumber(self, nums: List[int]) -> str:
        len_nums = len(nums)
        if sum(nums) == 0:
            return "0"
        if len_nums<1:
            return ""
        v_stack = [str(nums[0])]
        for i in range(1, len_nums):
            str_num = str(nums[i])
            for j in range(i):
                if str_num+v_stack[j] >= v_stack[j]+str_num:
                    v_stack.insert(j, str_num)
                    break
                elif j+1 == i:
                    v_stack.append(str_num)
        return "".join(v_stack)


a = Solution()
print(a.largestNumber([10,1]))